package com.spc.car.data.domain.adm.po;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.spc.car.common.utils.StringUtils;
import com.spc.car.data.entity.adm.AdmVehicleInfo;
import com.spc.car.data.util.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

@Data
public class AdmVehicleInfoPO<T> extends PageParam<T> {

    /**车辆名称*/
    @ApiModelProperty(value = "车辆名称", name = "carName")
    private String carName;

    @ApiModelProperty(value = "车牌号", name = "numberPlate")
    private String numberPlate;

    @ApiModelProperty(value = "车辆使用状态", name = "carUseStatus", notes = "01-可借用; 02-不提供借用; 03-已处置")
    private String carUseStatus;

    @ApiModelProperty( value = "座位数", name = "carSeatNum")
    private Integer carSeatNum;

    public Wrapper toWrapper() {
        LambdaQueryWrapper<AdmVehicleInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(this.carName), AdmVehicleInfo::getCarName, carName)
                .like(StringUtils.isNotBlank(this.numberPlate), AdmVehicleInfo::getNumberPlate, this.numberPlate)
                .eq(StringUtils.isNotBlank(this.carUseStatus), AdmVehicleInfo::getCarUseStatus, this.carUseStatus)
                .eq(!Objects.isNull(this.carSeatNum), AdmVehicleInfo::getCarSeatNum, carSeatNum)
                .orderByDesc(AdmVehicleInfo::getCreateTime);
        return wrapper;
    }
}
